﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Text;

public partial class OrderCart_OrderAddress : System.Web.UI.Page
{
    private string _usercode;
    private string _wlgs;
    public string UserCode
    {
        get { return _usercode; }
        set { _usercode = value; }
    }
    public string WLGS
    {
        get { return _wlgs; }
        set { _wlgs = value; }
    }
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSThemes();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = BasePage.WebTitle;
        if (!HttpContext.Current.User.Identity.IsAuthenticated)
        {
            Response.Redirect("../Users/Login.aspx");
        }
        else
        {
            UserCode = BasePage.GetValue(0);
            Init_ZWeight();
            Init_WLGS();
        }
        Session["Step"] = "2";
    }
    #region 初始化总重量
    private void Init_ZWeight()
    {
        decimal Zweight = 0;
        decimal Zamt = 0;
        List<Model.BUYPOCKETDETAIL> lists = new List<Model.BUYPOCKETDETAIL>();
        lists = new BLL.BUYPOCKETDETAIL().GetAllList(UserCode);
        foreach (Model.BUYPOCKETDETAIL buy in lists)
        {
            Zweight += buy.BPD_WEIGHT * buy.BPD_QTY;
            Zamt += buy.BPD_AAMT;
        }
        lbl_Sweight.Text = Zweight.ToString("f");
        lbl_Zamt.Text = Zamt.ToString("f");
        if (BasePage.GetFreeStandard() > 0)
        {
            lbl_freestandard.Visible = true;
            lbl_freestandard.Text = "(货款满" + BasePage.GetFreeStandard().ToString() + "免运费)";
            Hid_Free.Value = BasePage.GetFreeStandard().ToString();
        }
        else
        {
            lbl_freestandard.Visible = false;
            Hid_Free.Value = "0";
        }
    }
    #endregion

    #region 初始化物流公司
    private void Init_WLGS()
    {
        StringBuilder Sb = new StringBuilder();
        List<Model.TRANER> traners = new List<Model.TRANER>();
        traners = new BLL.TRANER().GetAllList(true);
        Sb.Append("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">");        
        if (traners.Count > 0)
        {
            Sb.Append("<tr class=\"r_bgcolor5\">");
            Sb.Append("<td >");
            //Sb.Append("<input id=\"rbtExpress\" type=\"radio\" name=\"DeliverType\" value=\"rbtExpress\" onclick=\"SelectDeliverType(this)\"/> <label for=\"rbtExpress\">快递送货上门</label>");
            //Sb.Append("</td>");
            //Sb.Append("<td><span style=\"color: #FF0000\">支持货到付款.</span></td>");
            //Sb.Append("<td></td></tr>");
            //Sb.Append("<tr><td colspan=\"3\" align=\"center\">");
            Sb.Append("<div class=\"wliu\" id=\"Deliver\"");
            Sb.Append("<ul>");
            foreach (Model.TRANER traner in traners)
            {
                if (traner.TRANER_AFTER == 1)
                {
                    Sb.Append("<li>");
                    Sb.Append("<input id=\"rbt" + traner.TRANER_CODE + "\" type=\"radio\" name=\"Deliver\" onclick=\"CalculateYF(this)\" value=\"" + traner.TRANER_CODE + "\"/><label for=\"rbtExpress\">" + traner.TRANER_NAME + "</label>");
                    Sb.Append("</li>");                    
                }
            }
            Sb.Append("</ul>");
            Sb.Append("</div>");
            Sb.Append("</td></tr>");
            //foreach (Model.TRANER traner in traners)
            //{
            //    if (traner.TRANER_AFTER == 0)
            //    {
            //        Sb.Append("<tr class=\"r_bgcolor5\">");
            //        Sb.Append("<td>");
            //        Sb.Append("<input id=\"rbt" + traner.TRANER_CODE + "\" type=\"radio\" name=\"DeliverType\" onclick=\"SelectDeliverType(this)\" value=\"" + traner.TRANER_CODE + "\"/> <label for=\"rbt" + traner.TRANER_CODE + "\">" + traner.TRANER_NAME + "</label>");
            //        Sb.Append("</td>");
            //        Sb.Append("<td><span style=\"color: #FF0000\">不支持货到付款。</span></td>");
            //        Sb.Append("<td></td>");
            //        Sb.Append("</tr>");
            //    }
            //}
        }
        else
        {
            Sb.Append("<tr class=\"r_bgcolor5\">");
            Sb.Append("<td>无物流信息，请联系客服! </td>");
            Sb.Append("</tr>");
        }
        Sb.Append("</table>");
        WLGS = Sb.ToString();
    }
    #endregion
}
